package ru.ifmo.filemanager.core;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class ActionSelectionListener extends SelectionAdapter {
	
	private final String name;
	private final Runnable action;
	
	ActionSelectionListener(String name, Runnable action) {
		this.name = name;
		this.action = action;
	}

	public void widgetSelected(SelectionEvent e) {
		try {
			action.run();
		} catch (Throwable ee) {
			Core.error("Error in action " + name, ee, false);
		}
	}
}
